package cn.tedu.hospital.management.dao.persist.repository.impl;

import cn.tedu.hospital.management.dao.persist.mapper.*;
import cn.tedu.hospital.management.dao.persist.repository.IHospitalRepository;
import cn.tedu.hospital.management.pojo.entity.*;
import cn.tedu.hospital.management.pojo.param.HospitalParam;
import cn.tedu.hospital.management.pojo.vo.HospitalHospitalVO;
import cn.tedu.hospital.management.pojo.vo.HospitalStandardVO;
import cn.tedu.hospital.management.pojo.vo.HospitalVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public class HospitalRepositoryImpl implements IHospitalRepository {

    @Autowired
    private HospitalMapper hospitalMapper;

    @Autowired
    private CityMapper cityMapper;
    @Autowired
    private LevelMapper levelMapper;
    @Autowired
    private ProvinceMapper provinceMapper;
    @Autowired
    private TypeMapper typeMapper;
    @Autowired
    private FieldMapper fieldMapper;


    @Override
    public int insert(Hospital hospital) {
        return hospitalMapper.insert(hospital);
    }

    @Override
    public Long hospitalIdByName(String hospitalName) {
        return hospitalMapper.hospitalIdByName(hospitalName);
    }

    @Override
    public Long cityIdByName(String cityName) {
        return cityMapper.cityIdByName(cityName);
    }

    @Override
    public Long levelIdByName(String levelName) {
        return levelMapper.levelIdByName(levelName);
    }

    @Override
    public Long provinceIdByName(String provinceName) {
        return provinceMapper.provinceIdByName(provinceName);
    }

    @Override
    public Long typeIdByName(String typeName) {
        return typeMapper.typeIdByName(typeName);
    }

    @Override
    public int insert(Field field) {
        return fieldMapper.insert(field);
    }

    @Override
    public void delectById(Long id) {
        hospitalMapper.deleteById(id);
        fieldMapper.deleteByHospitalId(id);
    }

    @Override
    public int updateCityIdBy(City city) {
        return cityMapper.updateById(city);
    }

    @Override
    public int updateHospitalIdBy(Hospital hospital) {
        return hospitalMapper.updateById(hospital);
    }

    @Override
    public int updateLevelIdBy(Level level) {
        return levelMapper.updateById(level);
    }

    @Override
    public int updateProvinceIdBy(Province province) {
        return provinceMapper.updateById(province
        );
    }

    @Override
    public int updateTypeIdBy(Type type) {
        return typeMapper.updateById(type);
    }

    @Override
    public List<HospitalHospitalVO> selectAll() {
        return hospitalMapper.selectAll();
    }


    @Override
    public int insertHospital(Hospital hospital) {

        return hospitalMapper.insert(hospital);
    }

    @Override
    public Long selectHospitalCityId(String name) {

        Long cityId = hospitalMapper.selectHospitalCityId(name);
        return cityId;
    }

    @Override
    public Long selectHospitalLevelId(String name) {

        Long levelId = hospitalMapper.selectHospitalLevelId(name);
        return levelId;
    }

    @Override
    public Long selectHospitalProvinceId(String name) {

        Long provinceId = hospitalMapper.selectHospitalProvinceId(name);
        return provinceId;
    }

    @Override
    public Long selectHospitalTypeId(String name) {

        Long typeId = hospitalMapper.selectHospitalTypeId(name);
        return typeId;
    }

    /*根据id删除医院*/
    @Override
    public int deleteById(Long id) {
        return hospitalMapper.deleteById(id);
    }

    /*根据id修改医院信息*/
    @Override
    public int updateById(Hospital hospital) {
        return hospitalMapper.updateById(hospital);
    }

    /*根据id查询医院信息*/
    @Override
    public HospitalStandardVO getStandardById(Long id) {
        return hospitalMapper.getStandardById(id);
    }

    @Override
    public List<HospitalVO> getHospitals(HospitalParam hospitalParam) {
        return hospitalMapper.selectHospitals(hospitalParam);
    }

    @Override
    public int avatar(Hospital hospital) {
        return hospitalMapper.avatar(hospital);
    }


}
